home *** CD-ROM | disk | FTP | other *** search
/ The Original Shareware 1.1 / The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso / 19 / madtrb11.zip / COPY.PAS < prev    next >
Pascal/Delphi Source File  |  1985-07-13  |  2KB  |  51 lines

  1. PROGRAM Copy;
  2.  
  3. {
  4. This program will copy any text file, including Pascal files,
  5. to a new file with the designated name.
  6.  
  7. Source: "COPY and List for Pascal Source Files", TUG Lines Volume I Issue 6
  8. Author: Harold Drake
  9. Application: All systems
  10. }
  11.  
  12. var
  13.   source:    string[14];              {name of source file}
  14.   target:    string[14];              {name of target file}
  15.   line:      string[80];              {one line of the file}
  16.   n:         integer;                 {index variable}
  17.   lgth:      integer;                 {length of filename string}
  18.   f:         text;                    {internal filename for source}
  19.   g:         text;                    {internal filename for target}
  20.   pascal:    boolean;                 {flag for pascal file extension}
  21. begin
  22.   write('Enter source name:  ');    readln(source);
  23.   pascal := true;
  24.   lgth := length(source);
  25.   for n := 1 to lgth do if source[n] = '.' then pascal := false;
  26.   if pascal then insert('.PAS',source,1+lgth);
  27.   if (not pascal) and (source[lgth] = '.') then delete(source,lgth,1);
  28.   assign(f,source);
  29.   write('Enter target name:  ');readln(target);
  30.   pascal := true;
  31.   lgth := length(target);
  32.   for n := 1 to lgth do if target[n] = '.' then pascal := false;
  33.   if pascal then insert('.PAS',target,1+lgth);
  34.   if (not pascal) and (target[lgth] = '.') then delete(target,lgth,1);
  35.   assign(g,target);
  36.   reset(f);
  37.   rewrite(g);
  38.   while not eof(f) do
  39.     begin
  40.       readln(f,line);
  41.       writeln(g,line);
  42.     end;
  43.   close(g);
  44.   close(f);
  45. end.
  46.  
  47.  
  48.  
  49.  
  50.  
  51.